//
//  HomeModels.swift
//  LeGou
//
//  Created by lxm on 2022/7/27.
//

import Foundation
import HandyJSON
struct HomeModels {
    struct SignInInfo : HandyJSON {
        var invite: Int = 0
        var inviteNumber: Int = 0
        var signNumber: Int = 0
        var task: Int = 0
        var taskNumber: Int = 0
    }
    
    struct BannerInfo : HandyJSON {
        var content = ""
        var createTime = ""
        var id: Int = 0
        var img = ""
        var remark = ""
        var sort: Int = 0
        var status: Int = 0
        var title = ""
        var urlHtml = ""
        var urlType: Int = 0
    }
}

// MARK: - 商品分类
struct GoodsCategory: HandyJSON {
    var name = ""
    var id = 0
    mutating func mapping(mapper: HelpingMapper) {
        mapper <<<
            self.name <-- ["cname","catName"]
        mapper <<<
            self.id <-- ["cid","catId"]
    }
}

// MARK: - 首页列表分类
struct HomeGoodsCategory {
    var cname : String
    var subTitlte : String
    var type : HomeListVC.ListType
}



class TBGoods : HandyJSON {
    required init(){}
    var activityEndTime = ""
    var activityStartTime = ""
    var activityType: Int = 0
    var actualPrice = 0.0
    var brand: Int = 0
    var brandId: Int = 0
    var brandName = ""
    var cid: Int = 0
    var commissionRate = 0.0
    var commissionType: Int = 0
    var couponConditions = ""
    var couponEndTime = ""
    var couponLink = ""
    var couponPrice = 0.0
    var couponReceiveNum: Int = 0
    var couponStartTime = ""
    var couponTotalNum: Int = 0
    var createTime = ""
    var dailySales: Int = 0
    var desc = ""
    var descScore: Int = 0
    var directCommission: Int = 0
    var directCommissionLink = ""
    var directCommissionType: Int = 0
    var discountCut: Int = 0
    var discountFull: Int = 0
    var discountType: Int = 0
    var discounts: Int = 0
    var dsrPercent: Int = 0
    var dsrScore: Int = 0
    var dtitle = ""
    var estimateAmount: Int = 0
    var freeshipRemoteDistrict: Int = 0
    var goldSellers: Int = 0
    var goodsId = ""
    var haitao: Int = 0
    var hotPush: Int = 0
    var hzQuanOver: Int = 0
    var id: Int = 0
    var inspectedGoods: Int = 0
    var itemLink = ""
    var mainPic = ""
    var marketGroup = ""
    var marketingMainPic = ""
    var monthSales: Int = 0
    var originalPrice = 0.0
    var quanMLink: Int = 0
    var saveTime = ""
    var sellerId = ""
    var servicePercent: Int = 0
    var serviceScore: Int = 0
    var shipPercent: Int = 0
    var shipScore: Int = 0
    var shopLevel: Int = 0
    var shopLogo = ""
    var shopName = ""
    var shopType: Int = 0
    var specialText = ""
    var subcid = ""
    var tbcid: Int = 0
    var teamName = ""
    var title = ""
    var twoHoursSales: Int = 0
    var updateTime = ""
    var video = ""
    var yunfeixian: Int = 0
    var userCommission = 0.0
    var commission = 0.0
    
    var commissionMoney : Double {
        get {
            commissionRate / 100 * actualPrice
        }
    }
}

struct TBGoodsDetail : HandyJSON {
    var actualPrice = 0.0
    var brand: Int = 0
    var brandId: Int = 0
    var brandName = ""
    var commissionRate = 0.0
    var commissionType: Int = 0
    var couponConditions = ""
    var couponEndTime = ""
    var couponId = ""
    var couponLink = ""
    var couponPrice = 0.0
    var couponReceiveNum: Int = 0
    var couponStartTime = ""
    var couponTotalNum: Int = 0
    var dailySales: Int = 0
    var desc = ""
    var descScore: Int = 0
    var detailPics = [DetailPicsModel]()
    var directCommission: Int = 0
    var directCommissionLink = ""
    var directCommissionType: Int = 0
    var discountCut: Int = 0
    var discountFull: Int = 0
    var discountType: Int = 0
    var discounts: Int = 0
    var dsrPercent: Int = 0
    var dsrScore: Int = 0
    var dtitle = ""
    var estimateAmount: Int = 0
    var goldSellers: Int = 0
    var goodsId = ""
    var hotPush: Int = 0
    var hzQuanOver: Int = 0
    var id: Int = 0
    var imgs = ""
    var inspectedGoods: Int = 0
    var isSubdivision: Int = 0
    var itemLink = ""
    var lowest: Int = 0
    var mainPic = ""
    var marketingMainPic = ""
    var monthSales: Int = 0
    var originalPrice = 0.0
    var quanMLink: Int = 0
    var reimgs = ""
    var sales24h: Int = 0
    var sellerId = ""
    var servicePercent: Int = 0
    var serviceScore: Int = 0
    var shipPercent: Int = 0
    var shipScore: Int = 0
    var shopLevel: Int = 0
    var shopName = ""
    var shopType: Int = 0
    var subdivisionId: Int = 0
    var subdivisionName = ""
    var subdivisionRank: Int = 0
    var teamName = ""
    var title = ""
    var twoHoursSales: Int = 0
    var video = ""
    var yunfeixian: Int = 0
    // 分享赚
    var commission = 0.0
    // 自购省
    var buyProvince = 0.0
    
    var quotaShare = 0.0
    var itemId = 0
    
    var commissionMoney : Double {
        get {
            commissionRate / 100 * actualPrice
        }
    }
    
    mutating func mapping(mapper: HelpingMapper) {
        mapper <<<
            self.detailPics <-- TransformOf<[DetailPicsModel], Any>(fromJSON: { (value) -> [DetailPicsModel]? in
                if let val = value as? String {
                    if let arr = val.zm.toModelArray(DetailPicsModel.self) {
                        return arr
                    }
                }
                return nil
            }, toJSON: { (theCode) -> String? in
                return theCode?.toJSONString()
            })
    }
}

struct DetailPicsModel: HandyJSON {
    var height = 0.0
    var img = ""
}

// 淘宝口令解析数据
struct TBKouLingInfo : HandyJSON {
    var tbGoods: TBGoodsDetail?
    var tbLink: TBLinkInfo?
}

// 淘宝转链信息
struct TBLinkInfo : HandyJSON {
    var actualPrice = ""
    var couponClickUrl = ""
    var couponEndTime = ""
    var couponInfo = ""
    var couponRemainCount = ""
    var couponStartTime = ""
    var couponTotalCount = ""
    var itemId = ""
    var itemUrl = ""
    var kuaiZhanUrl = ""
    var longTpwd = ""
    var maxCommissionRate = ""
    var minCommissionRate = ""
    var originalPrice = ""
    var shortUrl = ""
    var tpwd = ""
    mutating func mapping(mapper: HelpingMapper) {
        mapper <<<
            self.shortUrl <-- ["shortUrl","clickURL"]
    }
}

// MARK: - 转链
struct ChangeLinkModel: HandyJSON {
    var jdLink: JDLinkModel?
    var tbGoods: TBGoods?
    var tbLink: TBLinkModel?
}

struct JDLinkModel: HandyJSON {
    
}

struct TBLinkModel: HandyJSON {
    // 针对iOS14版本，增加对应能解析的长口令
    var longTpwd = ""
    // 短链接
    var shortUrl = ""
}
